//请求前缀
//var baseURL = "/dplus-fast/";
//var baseURL = "http://192.168.2.122:8080/dplus-manage-web/";

var baseURL = "http://localhost:8089/";//http://192.168.2.104:8089/
baseURL="";
//var contextPath = 'http://192.168.2.104:8081/dplus-etl-web';
var user = "";
//登录token
var token = localStorage.getItem("token");
//jquery全局配置
$.ajaxSetup({
    async:true,
    dataType: "json",
    cache: false,
    headers: {
        "token": token
    },
    xhrFields: {
        withCredentials: true
    },
    complete: function (xhr) {
        // console.log(xhr.responseJSON );
        //token过期，则跳转到登录页面
        if(typeof(xhr.responseJSON)!="undefined" ){
            if (xhr.responseJSON == null || xhr.responseJSON.code == 401) {
                parent.location.href = '/views/login.html';
            }
        }
        /*设置jqGrid表格序号列的宽度*/
        setFirstColumWidth();

    }
});

function validToken() {
    /*    if(!localStorage.getItem("token")) {
            return false;
        }*/
    var flag = false;
    $.ajax({
        type: "POST",
        url: baseURL + "sys/validateToken",
        async: false,
        contentType: "application/json",
        data: JSON.stringify({"token": !localStorage.getItem("token") ? "123456" : localStorage.getItem("token")}),
        success: function (r) {
            if (r.code == 0) {
                user = r.user;
                flag = true;
            } else {
                flag = false;
                // localStorage.removeItem("token");
            }
        }
    });
    return flag;
}

//如果返回true 则说明是Android

function is_weixin() {
     var ua = window.navigator.userAgent.toLowerCase();
     if (ua.match(/MicroMessenger/i) == 'micromessenger') {
         return true;
     } else {
         return false;
 　   }
}
//js判断手机操作系统(ios或者是Android)

 $(function () {
    var u = navigator.userAgent, app = navigator.appVersion;
    var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Linux') > -1; //g
    var isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
    if (isAndroid) {
       //这个是安卓操作系统
    }
    if (isIOS) {
　　　　//这个是ios操作系统
    }
});
//js判断是否是电脑端

//如果返回的是false说明当前操作系统是手机端，如果返回的是true则说明当前的操作系统是电脑端
function IsPC() {
    var userAgentInfo = navigator.userAgent;
    var Agents = ["Android", "iPhone",
        "SymbianOS", "Windows Phone",
        "iPad", "iPod"];
    var flag = true;
    for (var v = 0; v < Agents.length; v++) {
        if (userAgentInfo.indexOf(Agents[v]) > 0) {
            flag = false;
            break;
        }
    }
    return flag;
}




